package com.watchthelan.web.server;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import com.watchthelan.service.server.ServerManager;

public class ServersController implements Controller {
	private final Log logger = LogFactory.getLog(this.getClass());
	private ServerManager serverManager;

	public void setServerManager(ServerManager serverManager) {
		this.serverManager = serverManager;
	}

	public ModelAndView handleRequest(HttpServletRequest arg0,
			HttpServletResponse arg1) throws Exception {		
		Map<String, Object> myModel = new HashMap<String, Object>();
		myModel.put("servers", this.serverManager.getServers());
		return new ModelAndView("servers", "model", myModel);
	}
}
